<?php ob_start(); ?>
<?php 
require_once("auth.php"); ?>
<?php 
  $target = "uploaded/"; 
    $tt= "uploaded/"; 

 $target = $target . basename( $_FILES['filePicture']['name']) ; 
 $ok=1;
 $pname=$_POST['txtprdname'];
 $mcat=$_POST['ddlmcategory'];
 $scat=$_POST['ddlscategory'];
	$brand=$_POST['ddlbrand'];
	$model=$_POST['txtmodel'];
	$cost=$_POST['txtcost'];
	$det=$_POST['textdetails'];
	$available=$_POST['avilable'];
// Make sure the file was sent without errors
				 if($_FILES['filePicture']['error'] == 0) {
		 
// $dbLink = new mysqli('localhost', 'root', '', 'avi');
//$dbLink = new mysqli('118.139.179.89', 'ourshopping', 'Amrit!23', 'ourshopping');
$dbLink =mysql_connect("localhost","n02557866","s081490","n02557866_db");
            if(mysqli_connect_errno()) {
                die("MySQL connection failed: ". mysqli_connect_error());
            }

   $name = $dbLink->real_escape_string($_FILES['filePicture']['name']);
            $mime = $dbLink->real_escape_string($_FILES['filePicture']['type']);
            $data = $dbLink->real_escape_string(file_get_contents($_FILES  ['filePicture']['tmp_name']));
            $size = intval($_FILES['filePicture']['size']);

 //This is our size condition 
 if (@$uploaded_size > 350000) 
 { 
 echo "Your file is too large.<br>"; 
 $ok=0; 
 } 
 //This is our limit file type condition 
 if (@$uploaded_type =="text/php") 
 { 
 echo "No PHP files<br>"; 
 $ok=0; 
 } 
 //Here we check that $ok was not set to 0 by an error 
 if ($ok==0) 
 { 
 Echo "Sorry your file was not uploaded"; 
 } 
 //If everything is ok we try to upload it 
 else 
 { 
 if(move_uploaded_file($_FILES['filePicture']['tmp_name'], $target)) 
 { 
			$tt=$tt.$name;

		  // Gather all required data
          
            // Create the SQL query
            $query = "INSERT INTO items VALUES ('','$pname','$brand',$cost,'$model','$mcat','$scat','$det','$tt',$available)";
     
            // Execute the query
            $result = $dbLink->query($query);
            // Check if it was successfull
						

            if($result) {


				 header("location:displaycomputers.php?added=added");
			}
			else
			{
			
			echo mysqli_error($dbLink);
			}
		}
		}

		}
		    else
			{
				echo "error";
			}// $dbLink->close();

 ?>
<?php ob_flush();
?>